﻿using System;
using System.Collections.Generic;
using System.IO;
using ProjScan.Tools;

namespace ProjScan.ScanRule.CustomRules
{
	// Token: 0x02000204 RID: 516
	public class CSVRuleTableData
	{
		// Token: 0x06000F16 RID: 3862 RVA: 0x0000740F File Offset: 0x0000560F
		public CSVRuleTableData(string CSVPath)
		{
			this.LoadCSVData(CSVPath);
		}

		// Token: 0x06000F17 RID: 3863 RVA: 0x000434D4 File Offset: 0x000416D4
		private void LoadCSVData(string CSVPath)
		{
			this.colInfos = new List<ColumnInfo>();
			using (StreamReader streamReader = new StreamReader(CSVPath))
			{
				string text = streamReader.ReadLine();
				string[] array = text.Split(new char[]
				{
					','
				});
				foreach (string text2 in array)
				{
					ColumnInfo item = new ColumnInfo(ToolsHelper.TrimYH(text2.Trim()));
					this.colInfos.Add(item);
				}
				this.columnCount = this.colInfos.Count;
				string text3 = streamReader.ReadLine();
				string[] array3 = text3.Split(new char[]
				{
					','
				});
				List<Type> list = new List<Type>();
				for (int j = 0; j < array3.Length; j++)
				{
					string text4 = array3[j].ToUpper().Trim();
					string a = text4;
					if (!(a == "STRING"))
					{
						if (!(a == "FLOAT"))
						{
							if (a == "BOOL")
							{
								list.Add(typeof(bool));
							}
						}
						else
						{
							list.Add(typeof(float));
						}
					}
					else
					{
						list.Add(typeof(string));
					}
				}
				this.rowCount = 0;
				while (!streamReader.EndOfStream)
				{
					this.rowCount++;
					string text5 = streamReader.ReadLine();
					string[] array4 = text5.Split(new char[]
					{
						','
					});
					int k = 0;
					while (k < array4.Length)
					{
						string text6 = ToolsHelper.TrimYH(array4[k]);
						bool flag = list[k] == typeof(string);
						object val;
						if (flag)
						{
							val = text6.Trim();
							goto IL_211;
						}
						bool flag2 = list[k] == typeof(float);
						if (flag2)
						{
							val = float.Parse(text6);
							goto IL_211;
						}
						bool flag3 = list[k] == typeof(bool);
						if (flag3)
						{
							val = bool.Parse(text6);
							goto IL_211;
						}
						IL_227:
						k++;
						continue;
						IL_211:
						this.colInfos[k].AddData(val);
						goto IL_227;
					}
				}
			}
		}

		// Token: 0x040008E8 RID: 2280
		public List<ColumnInfo> colInfos;

		// Token: 0x040008E9 RID: 2281
		public int rowCount;

		// Token: 0x040008EA RID: 2282
		public int columnCount;
	}
}
